import requests
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.service import Service as EdgeService
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.action_chains import ActionChains
import time

# 设置浏览器驱动路径
edge_driver_path = "/home/huangxin/webdriver/msedgedriver"

# 创建 Edge 服务对象
edge_service = EdgeService(executable_path=edge_driver_path)

# 创建 Edge 浏览器对象，传递服务对象
driver = webdriver.Edge(service=edge_service)

# 打开登录页面
driver.get("https://www.aimatess.xyz/h5/#/pages/login/login")

time.sleep(50)
# 获取 Cookie
cookies = driver.get_cookies()
print(cookies)
# 关闭浏览器
# driver.quit()


# 将 Selenium 的 Cookie 转换为 requests 可用的格式
session = requests.Session()
for cookie in cookies:
    session.cookies.set(cookie['name'], cookie['value'])

# 使用带有 Cookie 的 session 发送请求
response = session.get("https://www.mtesifyme.com/api/v1/user/sign")
print(response.text)
